package nameless.aistudy.api.role.user.subjects.english.vocabulary;

import nameless.aistudy.domain.model.subjects.english.vocabulary.book.VocabularyBook;
import nameless.aistudy.domain.model.subjects.english.vocabulary.dto.VocabularyBookDTO;
import nameless.aistudy.domain.service.subjects.english.vocabulary.VocabularyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/subject/english/vocabulary")
@CrossOrigin(origins = "http://localhost:8080")
public class EnglishVocabularyController {

    @Autowired
    private VocabularyService vocabularyService;

    @GetMapping("/book/{bookId}")
    public VocabularyBookDTO getVocabularyBook(@PathVariable("bookId") Integer bookId) {
        return vocabularyService.getVocabularyBookDetails(bookId);
    }

    //废弃
    @GetMapping("/bookName/{bookId}")
    public String getBookName(@PathVariable("bookId") Integer bookId) {
        return vocabularyService.getBookName(bookId);
    }

    @GetMapping("/books")
    public List<VocabularyBook> getAllVocabularyBooks() {
        return vocabularyService.getAllVocabularyBooks();
    }
}
